from ..extensions import db
from datetime import datetime


class House(db.Model):
    __tablename__ = 'houses'
    
    id = db.Column(db.BigInteger(), primary_key=True, autoincrement=True, comment='房屋ID')
    name = db.Column(db.String(255), nullable=False, comment='户号标识')
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, comment='创建时间')
    
    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'created_at': self.created_at.strftime('%Y-%m-%d %H:%M:%S') if self.created_at else None
        }